using System;
using bdddoc.core;
using jpboodhoo.bdd.contexts;
using jpboodhoo.bdd.mbunit;
using jpboodhoo.bdd.mbunit.standard.observations;
using resharperupdate.core.services;
using resharperupdate.core.services.impl;

namespace resharperupdate.core.tests
{
    public class ProductVersionParserSpecs
    {
        [Concern(typeof(ProductVersionParser))]
        public abstract class concerns : observations_for_a_sut_with_a_contract<IProductVersionParser, ProductVersionParser>{}

        public class when_checking_for_a_build_number : concerns
        {
            static int expected_build;
            static string product_version;
            static int result;

            context c = () =>
                                    {
                                        expected_build = 1711;
                                        product_version = "4.5.1711.21";
                                    };

            because b = () => result = sut.build(product_version);

            it should_find_the_expected_number = () =>
                                                             {
                                                                 result.should_be_equal_to(expected_build);
                                                             };
        }

        public class when_a_product_version_is_in_the_wrong_format : concerns
        {
            
            static string product_version;

            context c = () =>
                                    {
                                        product_version = "4.5.1711";
                                    };

            because b = () => doing(() => sut.build(product_version));

            it should_throw_an_exception = () =>
                                           exception_thrown_by_the_sut.should_not_be_null();
        }
    }
}